﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MathLab.Utils
{
  class VectorMultiply
  {
    public static double[] ScalarMultiplyVector(double[] vectorA, double[] vectorB)
    {
      if ((vectorA != null) && (vectorB != null) &&(3 == vectorA.Length) && (3 == vectorB.Length))
      {
        double[] resultVector = new double[3];
        resultVector[0] = (vectorA[1] * vectorB[2]) - (vectorA[2] * vectorB[1]);
        resultVector[1] = (vectorA[2] * vectorB[0]) - (vectorA[0] * vectorB[2]);
        resultVector[2] = (vectorA[0] * vectorB[1]) - (vectorA[1] * vectorB[0]);
        return resultVector;
      }
      else
      {
        throw new Exception("These vectors could not be scalar multiplied: Vectors 1x3 needed");
      }
    }
  }
}
